try:
    from langchain_chroma import Chroma
    from langchain_huggingface import HuggingFaceEmbeddings
    import torch
    from langchain.schema import Document
    print("✅ Chroma 导入成功")

    # 测试其他可能出问题的导入
    # import opentelemetry.util.types

    print("✅ OpenTelemetry 导入成功")

    # 加载嵌入模型
    embedding_model = HuggingFaceEmbeddings(
        model_name="./bge-base-zh-v1.5",
        model_kwargs={"device": "cuda" if torch.cuda.is_available() else "cpu"},
        encode_kwargs={
            "normalize_embeddings": True
        },  # 输出归一化向量，更适合余弦相似度计算
    )
    texts = [
    Document(
        page_content="这是第一个文档的内容",
        metadata={"source": "file1.txt", "page": 1}
    ),
    Document(
        page_content="这是第二个文档的内容",
        metadata={"source": "file2.txt", "page": 1}
    )
]
    # 嵌入并存储到向量数据库
    vectorstore = Chroma.from_documents(
        texts,  # 文档列表
        embedding_model,  # 嵌入模型
        persist_directory="vectorstore",  # 存储路径
    )


except ImportError as e:
    print(f"❌ 导入失败: {e}")